package com.we.util;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 * mybatis工具类
 */
public class MybatisUtils {

    public static SqlSession getSqlSession(){
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(MybatisUtils.class.getClassLoader().getResourceAsStream("mybatis-config.xml"));
        return factory.openSession(true);
    }

    public static void main(String[] args) {
        SqlSession sqlSession = getSqlSession();
        System.out.println(sqlSession);
    }
}
